
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <script>
        if(window!==top)
            top.location.replace(location.href);
    </script>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/plugin/layui/css/layui.css"/>
    <link rel="stylesheet" href="/static/css/admin.css"/>


    <title>系统登陆</title>
    <style>
        body {
            background-image: url("/static/images/login1.jpg");
            background-repeat: no-repeat;
            background-size: cover;
            background-position: center;
            background-attachment: fixed;

            min-height: 100vh;
        }

        body:before {
            content: "";
            background-color: rgba(0, 0, 0, .2);
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
        }

        .login-wrapper {
            max-width: 450px;
            padding: 20px;
            margin: 0 auto;
            position: relative;
            box-sizing: border-box;
            z-index: 2;
        }

        .login-wrapper > .layui-form {
            padding: 30px 40px;
            border-radius: 20px;
            background-color: rgba(255, 255, 255, 0.85);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
            border: 1px solid #e3edf7;
            transition: all 0.3s ease;
        }

        .login-wrapper > .layui-form > h2 {
            font-family: "华文琥珀", "Microsoft YaHei", Arial, sans-serif;
            font-size: 40px;
            font-weight: bold;
            color: #5fb8a8;
            text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
            background: linear-gradient(to right, #5fb8a8, #4da192);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            letter-spacing: 4px;
            text-align: center;
            line-height: 1;
            margin-bottom: 20px;
        }

        .login-wrapper > .layui-form > h2 .sub-title {
            display: inline-block;
            text-indent: 120px;
            font-size: 24px;
            letter-spacing: 1px;
            color: #5fb8a8;
            background: linear-gradient(to right, #5fb8a8, #4da192);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .login-wrapper > .layui-form > .layui-form-item {
            margin-bottom: 25px;
            position: relative;
        }

        .login-wrapper > .layui-form > .layui-form-item:last-child {
            margin-bottom: 0;
        }

        .login-wrapper > .layui-form > .layui-form-item > .layui-input {
            height: 46px;
            line-height: 46px;
            border-radius: 20px;
            padding-left: 15px;
            font-size: 16px;
            border: 1px solid #d1e3f0;
            background-color: #f5faff;
            box-shadow: 0 3px 6px rgba(158, 220, 207, 0.4);
            color: #333;
            outline: none;
            transition: all 0.3s ease;
        }

        .login-wrapper > .layui-form > .layui-form-item > .layui-input:focus {
            border-color: #5fb8a8;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
        }

        .login-wrapper > .layui-form .layui-btn-fluid {
            height: 48px;
            line-height: 48px;
            font-size: 16px;

        }

        .login-wrapper > .layui-form > .layui-form-item > .layui-form-checkbox {
            margin: 0 !important;
            padding-left: 25px;
        }

        .login-copyright {
            color: #eee;
            padding-bottom: 20px;
            text-align: center;
            position: relative;
            z-index: 1;
        }

        @media screen and (min-height: 550px) {
            .login-wrapper {
                margin: -250px auto 0;
                position: absolute;
                top: 50%;
                left: 0;
                right: 0;
                width: 100%;
            }

            .login-copyright {
                position: absolute;
                bottom: 0;
                right: 0;
                left: 0;
            }
        }
    </style>
</head>
<body>
<div class="login-wrapper layui-anim layui-anim-scale">
    <form class="layui-form">
        <h2>
            沧州师范学院<br>
            <span class="sub-title">——线上教育计划</span>
        </h2>


        <div class="layui-form-item layui-input-icon-group">
            <input class="layui-input" id="username" name="username" value="admin" placeholder="请输入登录账号" autocomplete="off"
                   lay-verType="tips" lay-verify="required" required/>
        </div>
        <div class="layui-form-item layui-input-icon-group">
            <input class="layui-input" id="pwd" name="password" value="123456" placeholder="请输入登录密码" type="password"
                   lay-verType="tips" lay-verify="required" required/>
        </div>

        <div class="layui-form-item">
            <input type="checkbox" id="remember" name="remember" title="记住密码" lay-skin="primary" checked>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn layui-btn-fluid" lay-filter="loginSubmit" lay-submit="">登录</button>
        </div>

    </form>
</div>
<script th:src="@{/static/plugin/layui/layui.js}"></script>
<script>
    layui.use(['layer','form'],function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form
        $('.login-wrapper').removeClass('layui-hide');

        //登陆事件
        form.on('submit(loginSubmit)',function(data){
            console.log('login click');

            // 设置按钮文字 禁止点击
            $(data.elem).attr('disabled',true).text('登陆中....');
            // 网络请求
            var loadIndex = layer.load(2);
            console.log(JSON.stringify(data.field));
            $.ajax({
                type:'POST',
                url:"/login.do",
                data:data.field,
                dataType:'json',
                beforeSend:function(){

                },
                success:function(res){
                    console.log(res);
                    layer.close(loadIndex);
                    if(res.code==0){
                        $(data.elem).attr('disabled',true).text('登陆成功');
                        layer.msg('登陆成功',{
                            icon:1,
                            time:1500
                        });
                        // 延迟跳转到首页
                        // 延迟3秒跳转到首页-->
                        setTimeout(function (){
                            if(res.data.role=="管理员"){
                                window.location.href = "/index"
                            }else if(res.data.role==="班主任"){
                                window.location.href = "/chargerindex";
                            }else if(res.data.role=="授课教师"){
                                window.location.href = "/classExpertIndex";
                            }
                            else if(res.data.role=="指导教师"){
                                window.location.href = "/homeworkExpertIndex";
                            }else if(res.data.role=="二级学院用户"){
                                window.location.href = "/SCuserIndex";
                            }
                        },2000);
                        return false;
                    }else {
                        layer.msg(res.msg,{
                            icon:2,
                            anim:6
                        });
                        setTimeout(function (){
                            $(data.elem).text('登录').removeAttr('disabled');
                        },1000);
                    }
                }
            })
            return false;
        })

    })
</script>
</body>
</html>
